package com.jule.teenpatti.mail.model;

import com.jule.core.jedis.StoredObj;
import com.jule.teenpatti.mail.dao.bean.MailAttachmentConfigModel;
import lombok.Data;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Data
public class MailAttAchmentMap extends StoredObj {
    /**
     * <mailConfigId,<id,MailAttachmentConfigmdo>>
     */
    private Map<Integer, Map<Integer, MailAttachmentConfigModel>> allMailArgs = new ConcurrentHashMap<>();

    /**
     * 添加邮件配置信息
     *
     * @param list
     */
    public void addItem(List<MailAttachmentConfigModel> list) {
        Iterator<MailAttachmentConfigModel> iter = list.iterator();
        while (iter.hasNext()) {
            MailAttachmentConfigModel mailConfig = iter.next();
            Map<Integer, MailAttachmentConfigModel> map = allMailArgs.get(mailConfig.getId());
            if (map == null) {
                map = new ConcurrentHashMap<>();
            }
            map.put(mailConfig.getId(), mailConfig);
            allMailArgs.put(mailConfig.getMail_id(), map);
        }
    }
}
